package control;

import view.View;
import model.Model;
import javax.swing.tree.MutableTreeNode;

public class Control {
	
	private static Control control=new Control();
	private Model model;
	private View view;
	
	private Control(){
		
	}
	//must be called after Model and View are initialized
	public void init(){
		model=Model.getModel();
		view=View.getView();
	}

	public static Control getControl(){
		return control;
	}
		
	//is called when the user requests to save tagdata
	//starts the save routine
	public void enteredData(){
		model.editCurMP3TagData();
	}
	//is called when the user clicks on the cover thumbnail
	//opens the frontcover window
	public void coverClicked(){
		view.showFrontCover();
	}
	//is called when the user selects a new jtree element
	//checks if the element is an mp3 , if so, requests
	//an update of the file information
	public void newTreeElementSelected(MutableTreeNode node){
		if (node instanceof model.MP3Node) model.selectNewCurrentMP3((model.MP3Node)node); 
	}
}
